To gain access to the GDevice record for a video device--for example, to determine the size and pixel depth of its attached screen--your application needs to get a handle to that record.
Your application can use the GetDeviceList function to obtain a handle to the first GDevice record in the device list, the GetGDevice function to obtain a handle to the GDevice record for the current device, the GetMainDevice function to obtain a handle to the GDevice record for the main screen, and the GetMaxDevice function to obtain a handle to the GDevice record for the video device with the greatest pixel depth.
All existing GDevice records are linked together in the device list. After using one of these functions to obtain a handle to one of the GDevice records in the device list, your application can use the GetNextDevice function to obtain a handle to the next GDevice record in the list.
Two related functions, GetGWorld and GetGWorldDevice , also allow you to obtain handles to GDevice records. To get the GDevice record for the current device, you can use the GetGWorld function. To get a handle to the GDevice record for a particular offscreen graphics world, you can use the GetGWorldDevice function. These two functions are described in the next chapter, "Offscreen Graphics Worlds."
To obtain a handle to the GDevice record for the current device, use the GetGDevice function.
FUNCTION GetGDevice: GDHandle;
The GetGDevice function returns a handle to the GDevice record for the current device. (At any given time, exactly one video device is the current device--that is, the one on which drawing is actually taking place.)
Color QuickDraw stores a handle to the current device in the global variable TheGDevice .
To obtain a handle to the first GDevice record in the device list, use the GetDeviceList function.
FUNCTION GetDeviceList: GDHandle;
The GetDeviceList function returns a handle to the first GDevice record in the global variable DeviceList .
The GetDeviceList function may move or purge memory blocks in the application heap. Your application should not call this function at interrupt time.
Listing 3 illustrates the use of this function.
To obtain a handle to the GDevice record for the main screen, use the GetMainDevice function.
FUNCTION GetMainDevice: GDHandle;
The GetMainDevice function returns a handle to the GDevice record that corresponds to the main screen--that is, the one containing the menu bar.
A handle to the main device is kept in the global variable MainDevice .
The GetMainDevice function may move or purge memory blocks in the application heap. Your application should not call this function at interrupt time.
Listing 3 illustrates the use of this function.
To obtain a handle to the GDevice record for the video device with the greatest pixel depth, use the GetMaxDevice function.
FUNCTION GetMaxDevice (globalRect: Rect): GDHandle;
After using the GetDeviceList function to obtain a handle to the first GDevice record in the device list, GetGDevice to obtain a handle to the GDevice record for the current device, GetMainDevice to obtain a handle to the GDevice record for the main screen, or GetMaxDevice to obtain a handle to the GDevice record for the video device with the greatest pixel depth, you can use the GetNextDevice function to obtain a handle to the next GDevice record in the list.
FUNCTION GetNextDevice (curDevice: GDHandle): GDHandle;
The GetNextDevice function returns a handle to the next GDevice record in the device list. If there are no more GDevice records in the list, it returns NIL .
The GetNextDevice function may move or purge memory blocks in the application heap. Your application should not call this function at interrupt time.
Listing 3 illustrates the use of this function.